package com.jintian.smart.kernel.switching.dto;

/**
 * TransferMessage的消息类型
 */
public enum MessageType {
    DataPacket(DataPacket.class), FileDataPacket(FileDataPacket.class);

    private final Class<?> bodyClass;

    private MessageType(Class<?> bodyClass) {
        this.bodyClass = bodyClass;
    }

    public Class<?> getMessageBodyClass() {
        return this.bodyClass;
    }

    public static MessageType valueOf(Class<?> clazz) {
        for (MessageType e : MessageType.values()) {
            if (e.getMessageBodyClass().equals(clazz)) {
                return e;
            }
        }
        throw new IllegalArgumentException("不支持的消息类型:" + clazz.getName());
    }
}
